home *** CD-ROM | disk | FTP | other *** search
/ Aminet 4 / Aminet 4 - November 1994.iso / aminet / comm / fido / shelter191a.lha / rexx / RFH.rexx < prev    next >
OS/2 REXX Batch file  |  1994-07-29  |  20KB  |  504 lines

  1. /**/
  2. v="$VER: RFH Rexx WPL Mailer File Request Function Host Williamson 55.11"
  3. if arg()=0 then exit
  4. parse arg wplport line .
  5. LG=lower(wplport)'wpl';line=strip(line);myport="RFH"line;app="RFH"line
  6. Options failat 99
  7. Options Results
  8. numeric digits 14
  9. Signal On Syntax
  10. sv="v"right(v,5);cr='0D'x;lf="0A"x;quote='"';LBUF="";ABUF="";MBUF=""
  11.  
  12. if showlist('P',myport) then do;address "LOGPROC" 'Putlog 'LG time() line app': 'myport' already open';exit 10;end
  13. if ~openport(myport) then do;address "LOGPROC" 'Putlog 'LG time() line app': Could not open 'myport', quitting';exit 10;end
  14. call setconfig
  15. if Priority~=0 then oldpri=Pragma('Priority',Priority)
  16. address "LOGPROC" 'Putlog 'LG time() line app sv myport 'Ready, Priority: 'priority
  17. quitflag=0
  18. do forever
  19.   drop entry RFunc cmdword junk Baud H_A Infile Listed R_A R_S
  20.   if quitflag=1 then leave
  21.   t=waitpkt(myport)
  22.   do ff=1
  23.     p=getpkt(myport)
  24.     if c2d(p)=0 then leave ff
  25.     RFunc=getarg(p)
  26.     cmdword=(upper(word(RFunc,1)))
  27.     if cmdword="REQ" | cmdword="RFHCFG" | cmdword="RFHEXIT" then call reply(p,0)
  28.     else call reply(p,5)
  29.     select
  30.       when cmdword="REQ" then do
  31.         Parse var RFunc junk' 'baud H_A Infile Listed R_A R_S
  32.         xfq_site_object=XfqGetAddress(R_A)
  33.         if ~XfqHoldMailer(xfq_site_object) then do
  34.           address "LOGPROC" 'Putlog 'LG time() line app 'HOLD Failed:'XFQERRORMSG R_A
  35.           drop XFQERRORCODE XFQERRORMSG
  36.         end;else call do_req()
  37.       end
  38.       when cmdword="RFHEXIT" then quitflag=1
  39.       when cmdword="RFHCFG" then call setconfig()
  40.       otherwise nop
  41.     end
  42.   end
  43. end
  44. address "LOGPROC" 'Putlog 'LG time() line app 'port closed'
  45. exit
  46.  
  47. do_req:
  48. parse var R_A hisaddress.domain '#' hisaddress.zone ':' hisaddress.net '/' hisaddress.node '.' hisaddress.point
  49. R_S=strip(R_S)
  50. if R_S="" then R_S="Unknown Sysop"
  51. address "LOGPROC" 'Putlog 'LG time() Line app sv 'Serving 'R_S' of 'R_A' on 'upper(wplport)||line
  52. LBUF="";ABUF="";MBUF="";pbuf="";tlist="T:RFH_t"Line;ulist="T:RFH_u"Line;a=0;b=0;i=0;x=0;Sent=0;TBytes=0
  53. LBUF=LBUF||date() time()' RFH Serving 'R_S' of 'R_A' on 'upper(wplport)||line||lf
  54. parse var H_A myaddress.domain '#' myaddress.zone ':' myaddress.net '/' myaddress.node '.' myaddress.point
  55. if ~ReqPoint & (hisaddress.point > "0") then do
  56.   address "LOGPROC" 'Putlog 'LG time() Line "Refusing Request! Points Not Supported!"
  57.   LBUF=LBUF||date() time() Line' Refusing request from 'R_S' of 'R_A' -> Points Not Allowed'lf
  58.   call writepkt('File request terminated: Points are not currently served.'cr)
  59.   call GoodBye()
  60.   return
  61. end
  62. if ~ReqUnlisted & ~Listed then do
  63.   address "LOGPROC" 'Putlog 'LG time() Line "Refusing Request! Unlisted Systems Not Supported!"
  64.   LBUF=LBUF||date() time() Line' Refusing request from 'R_S' of 'R_A' -> Unlisted System'lf
  65.   call writepkt('File request terminated: Unlisted System ('R_A')'cr)
  66.   call GoodBye()
  67.   return
  68. end
  69. if EXCLUDE.0~=0 then
  70. do zz=1 to EXCLUDE.0
  71.   if upper(R_A)=upper(Exclude.zz) then do
  72.     address "LOGPROC" 'Putlog 'LG time() Line "Refusing Request! Excluded Node!"
  73.     LBUF=LBUF||date() time() Line' Refusing request from 'R_S' of 'R_A' -> Excluded Node!'lf
  74.     call writepkt('File request terminated: Your system is not authorized to request files here.'cr)
  75.     call GoodBye()
  76.     return
  77.   end
  78. end
  79. AcctFile=AcctPath||translate(R_A,'...','#:/')
  80. if exists(AcctFile) then do
  81.   call open('Acct',AcctFile,'R')
  82.   FirstDate=readln('Acct')
  83.   LastDate=readln('Acct')
  84.   NumReqs =readln('Acct')
  85.   ReqFiles=readln('Acct')
  86.   ReqBytes=readln('Acct')
  87.   LastBytes=readln('Acct')
  88.   UserCalls=readln('Acct')
  89.   call close('Acct')
  90.   if LastDate~=Date() then LastBytes=0
  91.   UserCalls=UserCalls+1
  92. end;else do
  93.   FirstDate=Date();LastDate=Date()
  94.   NumReqs=0;ReqFiles=0;ReqBytes=0;LastBytes=0;UserCalls=0
  95. end
  96. NumRequested=1
  97. if ~open('in',Infile,'R') then do
  98.   address "LOGPROC" 'Putlog 'LG time() Line "Unable to read "Infile
  99.   LBUF=LBUF||date() time() Line Infile' from 'R_S' of 'R_A' -> Not Found'lf
  100.   call GoodBye()
  101.   return
  102. end
  103. do while ~eof('in')
  104.   FName.NumRequested=upper(readln('in'))
  105.   MName.NumRequested=""
  106.   if left(FName.NumRequested,1)=";" then iterate
  107.   if left(FName.NumRequested,3)="---" then iterate
  108.   if right(FName.NumRequested,1)=D2C('13') then FName.NumRequested=left(FName.NumRequested,Length(FName.NumRequested)-1)
  109.   if length(FName.NumRequested) < 1 then leave
  110.   Update.NumRequested=""
  111.   Password.NumRequested=""
  112.   if words(FName.NumRequested) > 1 then do
  113.     if left(word(FName.NumRequested,2),1)="!" then Password.NumRequested=SubStr(Word(FName.NumRequested,2),2)
  114.     if left(word(FName.NumRequested,2),1)="+" then Update.NumRequested=Word(FName.NumRequested,2)
  115.     else if left(word(FName.NumRequested,2),1)="-" then Update.NumRequested=Word(FName.NumRequested,2)
  116.     else if words(FName.NumRequested)=3 then do
  117.       if left(word(FName.NumRequested,3),1)="!" then Password.NumRequested=SubStr(Word(FName.NumRequested,3),2)
  118.       if left(word(FName.NumRequested,3),1)="+" then Update.NumRequested=Word(FName.NumRequested,3)
  119.       else if left(word(FName.NumRequested,3),1)="-" then Update.NumRequested=Word(FName.NumRequested,3)
  120.     end
  121.     FName.NumRequested=word(FName.NumRequested,1)
  122.   end
  123.   NumRequested=NumRequested+1
  124. end
  125. call close('in')
  126. NumRequested=NumRequested-1
  127. call FindRequests
  128. do a=1 to NumRequested
  129.   if (MaxReqNames > 0) & (a > MaxReqNames) then SendFName.a.SentFiles=1
  130.   do b=1 to SendFName.a.SentFiles
  131.     if SendFName.a.b="File Not Found" then do
  132.       MBUF=MBUF||'Request Number 'a  'Requested: 'FName.a||cr'Error: File Not Found or Password Missing/Invalid'cr||cr
  133.       LBUF=LBUF||date() time()' 'FName.a' -=> Error: File Not Found'lf
  134.       iterate
  135.     end
  136.     if SendFName.a.b="File Not Available" then do
  137.       MBUF=MBUF||'Request Number 'a  'Requested: 'FName.a||cr'Error: File Is Not Available On This System'cr||cr
  138.       LBUF=LBUF||date() time()' 'FName.a' -=> Error: File Missing ['Password.a']'lf
  139.       iterate
  140.     end
  141.     if SendFName.a.b="Bad Password" then do
  142.       MBUF=MBUF||'Request Number 'a  'Requested: 'FName.a||cr'Error: File Not Found or Password Missing/Invalid'cr||cr
  143.       LBUF=LBUF||date() time()' 'FName.a' -=> Error: Bad Password ['Password.a']'lf
  144.       iterate
  145.     end
  146.     if SendFName.a.b="Too Many Bytes" then do
  147.       MBUF=MBUF||'Request Number 'a  'Requested: 'FName.a||cr'Error: Request Exceeded Maximum Requests or Byte count'cr||cr
  148.       LBUF=LBUF||date() time()' 'FName.a' -=> Error: Request Exceeded Byte count'lf
  149.       iterate
  150.     end
  151.     if MaxReqNames>0 & a>MaxReqNames | SendFName.a.b="Too Many Requests" then do
  152.       MBUF=MBUF||'Request Number 'a  'Requested: 'FName.a||cr'Error: Request Exceeded Maximum Requests or Byte count'cr||cr
  153.       LBUF=LBUF||date() time()' 'FName.a' -=> Error: Request Exceeded Maximum Requests'lf
  154.       iterate
  155.     end
  156.     if SubWord(SendFName.a.b,1,3)="Update request failed:" then do
  157.       MBUF=MBUF||'Request Number 'a  'Requested: 'FName.a||cr'Date : 'JDate.a.b||cr'Error: 'SendFName.a.b||cr||cr
  158.       LBUF=LBUF||date() time()' 'FName.a' -=> Error: 'SendFName.a.b||lf
  159.       iterate
  160.     end;else do
  161.       Sent=Sent+1
  162.       if MName.a.b~="" then do
  163.         MBUF=MBUF||'Request Number 'a  'Requested: 'FName.a||' Sent:'MName.a.b||cr'Size : 'FSize.a.b' bytes'cr'Desc : 'FDesc.a.b||cr||cr
  164.         LBUF=LBUF||date() time()' 'FName.a '['MName.a.b'] ('FSize.a.b' bytes)'lf
  165.       end;else do
  166.         MBUF=MBUF||'Request Number 'a  'Requested: 'FName.a||cr'Size : 'FSize.a.b' bytes'cr'Desc : 'FDesc.a.b||cr||cr
  167.         LBUF=LBUF||date() time()' 'FName.a' ('FSize.a.b' bytes)'lf
  168.       end
  169.     end
  170.   end
  171. end
  172. if (MaxReqNames>0) & (NumRequested>MaxReqNames) then MBUF=MBUF||'Remaining Requests skipped for exceeding request limits'cr
  173. MBUF=MBUF||cr'Sending 'Sent' file(s), 'TBytes' bytes this request.'cr||cr'You have made a total of 'NumReqs+1' FileRequest(s) for 'ReqFiles+Sent' files ('ReqBytes+TBytes' bytes)'cr
  174. MBUF=MBUF||cr'Files were requested from 'app sv' on 'H_A||cr
  175. call writepkt(MBUF)
  176. drop MBUF
  177. LBUF=LBUF||date() time()' Sending 'Sent' file(s), 'TBytes' bytes this request'lf||date() time()' Totals: 'NumReqs+1' request(s) for 'ReqFiles+Sent' file(s) ('ReqBytes+TBytes' bytes)'lf
  178. ABUF=ABUF||FirstDate||lf||Date()||lf||NumReqs+1||lf||ReqFiles+Sent||lf||ReqBytes+TBytes||lf||LastBytes+TBytes||lf||UserCalls||lf
  179. call GoodBye()
  180. Return
  181.  
  182. FindRequests:
  183. Num=NumRequested
  184. if (MaxReqNames~=0) & (NumRequested>MaxReqNames) then Num=MaxReqNames
  185. do ReqCount=1 to Num
  186.   address "LOGPROC" 'PutLog 'LG time() Line app "Searching for Req:"ReqCount":"FName.ReqCount" in "FREQLST
  187.   SentCount=1;notfound=1
  188.   SendFName.ReqCount.SentCount="File Not Found"
  189.   if SortedLst then sopt="-s"
  190.   if MatchFirst then address COMMAND 'Fsearch >'tlist FREQLST Fname.ReqCount '-o' sopt
  191.   else address COMMAND 'Fsearch >'tlist FREQLST Fname.ReqCount sopt
  192.   call open('tq',tlist,'r')
  193.   do while ~eof('tq')
  194.     SearchResult=strip(readln('tq'))
  195.     if SearchResult="" then Iterate
  196.     if SearchResult="!@ No match found" then do
  197.       SendFName.ReqCount.SentCount="File Not Found"
  198.       Leave
  199.     end
  200.     if MatchFirst then do
  201.       call sendifok
  202.       Leave
  203.     end
  204.     call sendifok
  205.     SentCount=SentCount+1
  206.     if MultiMagic | ~MatchFirst then Iterate;else Leave
  207.   end
  208.   call close('tq');call delete(tlist)
  209.   if SentCount=0 then SendFname.ReqCount.SentFiles=1
  210.   else if SentCount > 1 then SendFname.ReqCount.SentFiles=SentCount-1
  211.   else SendFname.ReqCount.SentFiles=SentCount
  212. end
  213. Return
  214.  
  215. sendifok:
  216. sendit=1
  217. if index(SearchResult,'!')=0 then SendFname.ReqCount.SentCount=upper(subword(SearchResult,2))
  218. else do
  219.   if upper(Password.ReqCount)~=strip(upper(delstr(word(SearchResult,2),1,1))) then do
  220.     SendFName.ReqCount.SentCount="Bad Password"
  221.     sendit=0
  222.   end;else SendFname.ReqCount.SentCount=upper(subword(SearchResult,3))
  223. end
  224. if ~sendit then return sendit
  225. if ~exists(SendFName.ReqCount.SentCount) then do
  226.   SendFName.ReqCount.SentCount="File Not Available"
  227.   sendit=0
  228. end;else do
  229.   FName.ReqCount.SentCount=get_fn(SendFName.ReqCount.SentCount)
  230.   filestats=statef(SendFName.ReqCount.SentCount)
  231.   FSize.ReqCount.SentCount=word(filestats,2)
  232.   TBytes=TBytes+FSize.ReqCount.SentCount
  233.   if MaxBytes>0 & (TBytes>MaxBytes) then do
  234.     SendFName.ReqCount.SentCount="Too Many Bytes"
  235.     TBytes=TBytes-FSize.ReqCount.SentCount
  236.     sendit=0
  237.   end
  238.   if (MaxDaily > 0) & (TBytes+LastBytes > MaxDaily) then do
  239.     SendFName.ReqCount.SentCount="Exceeded Daily Limit"
  240.     TBytes=TBytes-FSize.ReqCount.SentCount
  241.     sendit=0
  242.   end
  243.   FDesc.ReqCount.SentCount=subword(filestats,8)
  244.   if FDesc.ReqCount.SentCount="" then FDesc.ReqCount.SentCount="Sorry, description is unavailable"
  245.   if fd~="NOTE" then do
  246.     if fd="DLG" then FDesc.ReqCount.SentCount=get_dlgfd()
  247.     else if fd="TA" then FDesc.ReqCount.SentCount=get_tadesc()
  248.     else if fd="EXL" then FDesc.ReqCount.SentCount=get_exldesc()
  249.   end  
  250.   if Update.ReqCount ~="" then do
  251.     UDT.ReqCount=left(Update.ReqCount,1)
  252.     if substr(Update.ReqCount,2,1)="U" then do
  253.       Update.ReqCount=SubStr(Update.ReqCount,3)
  254.       UDT.Human=1
  255.     end;else do
  256.       Update.ReqCount=SubStr(Update.ReqCount,2)
  257.       UDT.Human=0
  258.     end
  259.     if UDT.Human then do
  260.       if length(strip(Update.ReqCount)) >6 then do
  261.         cktime=1
  262.         cmd='List DATES 'SendFName.ReqCount.SentCount' LFORMAT="%D%T" TO 'ulist
  263.       end;else do
  264.         cktime=0
  265.         cmd='List DATES 'SendFName.ReqCount.SentCount' LFORMAT="%D" TO 'ulist
  266.       end
  267.       Address Command cmd
  268.       call open('UFile',ulist,'R')
  269.       UpDt.ReqCount.SentCount=readln('UFile')
  270.       call close('UFile')
  271.       call Delete(ulist)
  272.       if cktime then UpDt.ReqCount.SentCount=space(translate(UpDt.ReqCount.SentCount,"",":"),0)
  273.       Mon=right('00'||(pos(substr(UpDt.ReqCount.SentCount,4,3),'JanFebMarAprMayJunJulAugSepOctNovDec')+2)/3,2)
  274.       if cktime then Jdate.ReqCount.SentCount=right(UpDt.ReqCount.SentCount,2)||Mon||left(UpDt.ReqCount.SentCount,2)||right(UpDt.ReqCount.SentCount,8)
  275.         else Jdate.ReqCount.SentCount=right(UpDt.ReqCount.SentCount,2)||Mon||left(UpDt.ReqCount.SentCount,2)
  276.     end;else do
  277.       x=statef(SendFName.ReqCount.SentCount)
  278.       JDate.ReqCount.SentCount=(86400 * 365 * 8)+(2 * 86400)+(((word(x,5))*86400)+(word(x,6)*60))
  279.     end
  280.     if (UDT.ReqCount="+") & (JDate.ReqCount.SentCount < Update.ReqCount) then do
  281.       SendFName.ReqCount.SentCount="Update request failed: File older than requested."
  282.       sendit=0
  283.     end
  284.     if (UDT.ReqCount="-") & (JDate.ReqCount.SentCount > Update.ReqCount) then do
  285.       SendFName.ReqCount.SentCount="Update request failed: File newer than requested."
  286.       sendit=0
  287.     end
  288.   end
  289. end
  290. if sendit then do
  291.   Mname.ReqCount.SentCount=get_fn(SendFname.ReqCount.SentCount)
  292.   if Fname.ReqCount=Mname.ReqCount.SentCount then Mname.ReqCount.SentCount=""
  293.   call queueadd(SendFName.ReqCount.SentCount,4)
  294. end
  295. return sendit
  296.  
  297. writepkt:
  298. magicnum=x2d(time('s'))+randu(x2d(Pragma('ID')))+(randu(x2d(time('s')))*999999)+(random()*1000000)
  299. serial=reverse(right("0000"x||c2x(magicnum),8))
  300. packet_name="T:"serial".PKT"
  301. d=date("S");t=time("N")
  302. parse var t hh":"mm":"ss
  303. yr=reverse(right("00"x||d2c(left(d,4)),2))
  304. mh=reverse(right("00"x||d2c((substr(d,5,2)-1)),2))
  305. dy=reverse(right("00"x||d2c(substr(d,7,2)),2))
  306. hr=reverse(right("00"x||d2c(hh),2))
  307. mn=reverse(right("00"x||d2c(mm),2))
  308. sc=reverse(right("00"x||d2c(ss),2))
  309. zo=reverse(right("00"x||d2c(myaddress.zone),2))
  310. ndo=reverse(right("00"x||d2c(myaddress.node),2))
  311. nto=reverse(right("00"x||d2c(myaddress.net),2))
  312. po=reverse(right("00"x||d2c(myaddress.point),2))
  313. zd=reverse(right("00"x||d2c(hisaddress.zone),2))
  314. ndd=reverse(right("00"x||d2c(hisaddress.node),2))
  315. ntd=reverse(right("00"x||d2c(hisaddress.net),2))
  316. pd=reverse(right("00"x||d2c(hisaddress.point),2))
  317. pbuf=ndo||ndd||yr||mh||dy||hr||mn||sc||copies("00"x,2)||"0200"x||nto||ntd||"DA"x||d2c(substr(sv,2,2))||copies("00"x,8)
  318. pbuf=pbuf||zo||zd||copies("00"x,2)||reverse(right("01"x||"00"x,2))||"00"x||d2c(substr(sv,5,2))||reverse(right("00"x||"01"x,2))
  319. pbuf=pbuf||zo||zd||po||pd||"ROOF"||"0200"x||ndo||ndd||nto||ntd||"11000000"x||left(date(),6) right(date(),2) "" time()||"00"x||R_S||"00"x
  320. pbuf=pbuf||sysop||"00"x||"Results of your file request"||"00"x
  321. if myaddress.zone~=hisaddress.zone then pbuf=pbuf||"01"x||"INTL" hisaddress.zone":"hisaddress.net"/"hisaddress.node myaddress.zone":"myaddress.net"/"myaddress.node||cr
  322. else pbuf=pbuf||"01"x||"MSGTO:" hisaddress.zone":"hisaddress.net"/"hisaddress.node||cr
  323. if myaddress.point~=0 then pbuf=pbuf||"01"x||"FMPT" myaddress.point||cr;if hisaddress.point~=0 then pbuf=pbuf||"01"x||"TOPT" hisaddress.point||cr
  324. pbuf=pbuf||"01"x||"MSGID: "myaddress.zone':'myaddress.net'/'myaddress.node'.'myaddress.point' 'd2x((date('I') * 86400)+time("S")+252460600) ||cr
  325. pbuf=pbuf||"01"x||"PID: Roof/"app sv||cr||"    Presenting "app sv", the WPL File Request ARexx Function Host"cr||cr
  326. pbuf=pbuf||cr'The following are the results of your File Request:'cr||cr||arg(1)||cr||cr||cr||"--- "app sv||cr||cr||"000000"x
  327. if ~open('packet',packet_name,"W") then do;address "LOGPROC" 'PutLog 'LG time() Line app "Couldn't open packet-file ["packet_name"]";return 20;end
  328. call writech('packet',pbuf);call close('packet');drop pbuf
  329. call queueadd(packet_name,5)
  330. return 0
  331.  
  332. queueadd:
  333. file=upper(arg(1))
  334. flags=arg(2)
  335. sendas=get_fn(file)
  336. work=NULL
  337. QUERY.XQ_NAME=file
  338. QUERY.XQ_SITE=xfq_site_object
  339. work=XfqFindWork(QUERY)
  340. if work=NULL then do
  341.   if ~XfqAddWorkQuick(R_A,file,sendas,120,flags) then do
  342.     address "LOGPROC" 'PutLog 'LG time() Line app 'Queue 'file' Failed:'XFQERRORMSG R_A
  343.     drop XFQERRORCODE XFQERRORMSG
  344.   end;else do
  345.     address "LOGPROC" 'PutLog 'LG time() Line app 'Queued 'file' as' sendas
  346.   end
  347. end;else do
  348.   call XfqUnlockWork(work)
  349.   address "LOGPROC" 'PutLog 'LG time() Line app file 'already queued'
  350. end
  351. if work~=NULL then call XfqDropObject(work)
  352. return 0
  353.  
  354. get_dlgfd:
  355. fn=translate(FDesc.ReqCount.SentCount,"",'1b'x)
  356. if ~open('dx',fn,'r') then return "Sorry, DLG deappion is unavailable"
  357. tmpbuf=readch('dx',word(statef(fn),2))
  358. call close('dx')
  359. return substr(tmpbuf,lastpos('00'x,tmpbuf)+1)
  360.  
  361. get_tadesc:
  362. fn=SendFName.ReqCount.SentCount||'.desc'
  363. if ~open('dx',fn,'r') then return "Sorry, TransAmiga deappion is unavailable"
  364. tmpbuf=readch('dx',word(statef(fn),2))
  365. call close('dx')
  366. return tmpbuf
  367.  
  368. get_exldesc: Procedure
  369. Arg FilePath
  370. TempComment="";TempPath=Translate(FilePath,"  ",":/")
  371. TempFile=Word(TempPath,Words(TempPath))
  372. TempPath=Left(FilePath,Length(FilePath)-Length(TempFile))
  373. If ~Exists(TempPath"_itemdata") then Return "NO EXCELSIOR COMMENT"
  374. FSize=Word(StateF(TempPath"_itemdata"),2)
  375. call Open("Items",TempPath"_itemdata","R")
  376. fileX=0
  377. do forever
  378.     if fileX * 170 >= FSize then break
  379.     FileName=""
  380.     call seek("Items",(filex*170),"B")
  381.     do forever
  382.         Char=ReadCH("Items")
  383.         If Char="00"x then Leave
  384.         FileName=FileName||Char
  385.     End
  386.     fileX=fileX+1
  387.     If Upper(FileName)=Upper(TempFile) then Do
  388.         Call Open("Data",TempPath"_Comments","R")
  389.         OffSet=((fileX-1) * 170) + 110
  390.         Call Seek("Items",OffSet,"B")
  391.         Pos=C2D(ReadCH("Items",4))
  392.         Call Seek("Data",Pos,"B")
  393.         Do Until Left(EComment,1) = "01"x
  394.             EComment=ReadLn("Data")
  395.             TempComment=TempComment||"0a"x||EComment
  396.         End
  397.         Call Close("Data")
  398.         TempComment=Strip(compress(TempComment,"01"x),"B","0a"x)
  399.         TempComment=Translate(TempComment,"0d"x,"0a"x)
  400.         If Pos("0d"x,TempComment)>0 then Do
  401.             NComment=""
  402.             Do CLoop=1 to Length(TempComment)
  403.                 NComment=NComment||SubStr(TempComment,CLoop,1)
  404.                 If SubStr(TempComment,CLoop,1)="0d"x then NComment=NComment||"       "
  405.             End
  406.             TempComment=Strip(NComment,"T")
  407.         End
  408.     End
  409. End
  410. Call Close("Items")
  411. If TempComment="" then Return "NO EXCELSIOR COMMENT"
  412. else Return TempComment
  413.  
  414. get_fn:
  415. if LastPos('/',arg(1))~=0 then return SubStr(arg(1),LastPos('/',arg(1))+1)
  416. else if LastPos(':',arg(1))~=0 then return SubStr(arg(1),LastPos(':',arg(1))+1)
  417. else return arg(1)
  418.  
  419. setconfig:
  420. if ~open('cfg',"RAM:RFH.cfg",'r') then 
  421.   if ~open('cfg',"CFG:RFH.cfg",'r') then do;address "LOGPROC" 'PutLog 'LG time() Line 'Could not read RFH.cfg';exit;end
  422. exidx=1
  423. fd="NOTE"
  424. do while ~eof('cfg')
  425.   lx=readln('cfg')
  426.   if lx="" | left(lx,1)=" " | left(lx,2)='/*' | left(lx,2)='*/' then iterate
  427.   parse var lx vn vv junkcomment
  428.   vn=upper(vn);vv=strip(vv)
  429.   select
  430.     when vn="PRIORITY" then priority=vv
  431.     when vn="REQPOINT" then ReqPoint=vv=="TRUE"
  432.     when vn="REQUNLISTED" then ReqUnListed=vv=="TRUE"
  433.     when vn="SORTEDLST" then SortedLst=vv=="TRUE"
  434.     when vn="MULTIMAGIC" then MultiMagic=vv=="TRUE"
  435.     when vn="MATCHFIRST" then MatchFirst=vv=="TRUE"
  436.     when vn="FD" then fd=vv    
  437.     when vn="FREQLST" then FreqLst=dequote(vv)
  438.     when vn="LOGFILE" then LogFile=dequote(vv)
  439.     when vn="ACCTPATH" then AcctPath=dequote(vv)
  440.     when left(vn,7)="EXCLUDE" then do
  441.       EXCLUDE.exidx=dequote(vv)
  442.       exidx=exidx+1
  443.     end
  444.     when vn="MAXBYTES" then MaxBytes=vv
  445.     when vn="MAXDAILY" then MaxDaily=vv
  446.     when vn="MAXREQNAMES" then MaxReqNames=vv
  447.     otherwise address "LOGPROC" 'Putlog 'LG time() Line 'Config Error:'lx
  448.   end
  449.   if exidx>0 then EXCLUDE.0=exidx-1;else EXCLUDE.0=0
  450. end
  451. call close('cfg')
  452. drop lx vv vn junkcomment exidx
  453. address "LOGPROC" 'Putlog 'LG time() Line app sv 'Config loaded'
  454. return
  455.  
  456. lower:
  457. return(bitor(arg(1),'20'x))
  458.  
  459. Syntax:
  460. call template_oops "Syntax(RC="||RC||")" sigl RC
  461. template_oops:
  462. parse arg what badline code
  463. address "LOGPROC" 'PutLog 'LG time() Line "ERROR "what" Line:"badline
  464. call GoodBye()
  465. exit
  466.  
  467. GoodBye:
  468. x=XfqReleaseMailer(xfq_site_object)
  469. call XfqDropObject(xfq_site_object)
  470. if work~=NULL then call XfqDropObject(work)
  471. call XfqClose()
  472. if ABUF~="" then do
  473.   address "LOGPROC" 'PutLog 'LG time() Line "Updating account"
  474.   call open('Acct',AcctFile,'W')
  475.   call Writech('Acct',ABUF||lf)
  476.   call close('Acct')
  477.   drop ABUF
  478. end
  479. LBUF=LBUF||date() time()' RFH session Ending'lf
  480. if LogFile~="" then do
  481.   if exists(LogFile) then call open('log',LogFile,'A');else call open('log',LogFile,'W')
  482.   call writech('log',LBUF||lf);call close('log')
  483. end;else do
  484.   i=1
  485.   loglen=length(LBUF)
  486.   do while i < loglen+1
  487.     alen=pos('0a'x, LBUF, i)-i
  488.     aline=substr(body,i,alen)
  489.     address "LOGPROC" 'PutLog 'LG Line aline
  490.     i=i+alen+1
  491.   end
  492.   drop alen aline i
  493. end
  494. drop LBUF
  495. call delete(infile)
  496. address "LOGPROC" 'PutLog 'LG time() Line 'RFH session with' R_A 'terminated'
  497. return 0
  498.  
  499. dequote:
  500. parse arg thing
  501. parse var thing '"' unq_thing '"'
  502. if unq_thing ~= "" then return unq_thing
  503. return thing
  504.